# -*- coding: utf-8 -*-


from openerp import models
from openerp.osv import osv, fields, orm


#增加users表中添加共享给字段
class res_users_ext(orm.Model):
    _inherit = 'res.users'
    _columns = {
        'share_to': fields.many2many('res.users', 'user_user_rel', 'source_id', 'dest_id', string=u'委托给'),
        }

    def __init__(self, pool, cr):
        # init_res = super(res_users_ext, self).__init__(pool, cr)
        # # duplicate list to avoid modifying the original reference
        # self.SELF_WRITEABLE_FIELDS = list(self.SELF_WRITEABLE_FIELDS)
        # self.SELF_WRITEABLE_FIELDS.append('share_to')
        # # duplicate list to avoid modifying the original reference
        # self.SELF_READABLE_FIELDS = list(self.SELF_READABLE_FIELDS)
        # self.SELF_READABLE_FIELDS.append('share_to')
        #
        init_res = super(res_users_ext, self).__init__(pool, cr)
        # duplicate list to avoid modifying the original reference
        self.SELF_WRITEABLE_FIELDS = list(self.SELF_WRITEABLE_FIELDS)
        self.SELF_WRITEABLE_FIELDS.extend(['share_to'])
        return init_res
